package com.leenmvc.core.base.result;

import java.util.List;

/**
 * 分页信息
 */
public class PageData<T> {

    /** 默认页码 */
    public final static int DEFAULT_PAGE = 1;

    /** 默认每页多少条数据 */
    public final static int DEFAULT_PAGESIZE = 10;

    public final static int MAX_PAGESIZE = 500;

    /* 当前页*/
    private int page;

    /* 每页多少条 */
    private int pageSize;

    /* 一共有几页*/
    private int pages;

    /* 共有几条数据*/
    private int total;

    protected int num;

    /* 数据 */
    private List<T> data;

    public PageData() {

    }

    public PageData(int page, int pageSize, int total, List<T> data) {
        this.page = page;
        this.pageSize = pageSize == 0 ? DEFAULT_PAGESIZE : pageSize;
        this.total = total;
        this.data = data;
        int i = this.total % this.pageSize > 0 ? 1 : 0;
        this.pages = this.total / this.pageSize + i;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }
}
